package unit7_Practice_5;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class xianshiyunxingshijian extends Thread{
	public void run(){
		synchronized(this){
			try{
			Thread.sleep((int)Math.random()*5000);
			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
	        //System.out.println(df.format(new Date()));// new Date()为获取当前系统时间
			System.out.println(xianshiyunxingshijian.currentThread().getName()+"   "+df.format(new Date()));
		}catch(InterruptedException e){
			System.out.println(xianshiyunxingshijian.currentThread().getName());
		}
			System.out.println(xianshiyunxingshijian.currentThread().getName()+"   "+Calendar.getInstance().getTimeInMillis());
	}
	}
	public static void main(String[] args) throws InterruptedException {
		// TODO Auto-generated method stub
		xianshiyunxingshijian thread1 = new xianshiyunxingshijian();
		xianshiyunxingshijian thread2 = new xianshiyunxingshijian();
		xianshiyunxingshijian thread3 = new xianshiyunxingshijian();
		thread1.start();
		thread2.start();
		thread3.start();
		try{
		Thread.sleep(2000);
		}catch(ArithmeticException e){
			System.out.println("Thread is wrong");
		}
		
	}

}
